package com.zj.base.base_act;

import android.content.Context;
import android.support.annotation.CallSuper;
import android.support.multidex.MultiDexApplication;

import com.zj.base.cache.FileUtils;
import com.zj.base.httpclien.HttpConfig;
import com.zj.base.R;
import com.zj.base.utils.DisplayUtils;
import com.zj.base.utils.ToastUtils;

import java.util.Map;

/**
 * Created by zhaojie on 2018/5/23.
 */

public abstract class IBaseApplication extends MultiDexApplication {

    private static IBaseApplication mContext;

    @Override
    @CallSuper
    public void onCreate() {
        super.onCreate();
        initBase();
    }

    private void initBase() {
        mContext = this;
        ToastUtils.init(this);
        FileUtils.init(getResources().getString(R.string.fileCacheName));
        DisplayUtils.init(this);
        HttpConfig.init(this, "Zj_HttpConfig error case :", new HttpConfig.HttpDataSet() {
            @Override
            public Map<String, String> getCookie() {
                return mContext.getCookie();
            }
        });
    }

    public static Context getAppContext() {
        return mContext.getContext();
    }

    protected abstract Context getContext();

    protected abstract Map<String, String> getCookie();
}
